package com.tianqu.tms.www.car.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsActionNotTimeout;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.www.car.controller.FindCarController;
import com.tianqu.tms.www.car.viewhelper.FindCarRecommendListViewHelper;

public class FindCarRecommendedListAction  extends TmsActionNotTimeout {
	private final int pageSize = 5;
	private Logger logger = Logger.getLogger(FindCarRecommendedListAction.class);
	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response, UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		String p1 = request.getParameter("memberId");
		String p2 = request.getParameter("pageNumber");
		int pageNumber = StringUtils.isNumeric(p2)?Integer.parseInt(p2):1;
		FindCarController controller =  new FindCarController();
		FindCarRecommendListViewHelper view = controller.FindCarRecommendedListController(p1, pageNumber, pageSize);
		request.setAttribute(TmsConstants.VIEWHELP,view );
		logger.debug(this.getClass().getName() + "#execute was completed.");
		return mapping.findForward(TmsConstants.SUCCESS);
	}
}
